-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Insertion Rework #4999
Merged
philipaconrad
merged 4 commits into
open-policy-agent:main
from
philipaconrad:set-insert-rework
Aug 15, 2022
Merged
Set Insertion Rework #4999
philipaconrad
merged 4 commits into
open-policy-agent:main
from
philipaconrad:set-insert-rework
Aug 15, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
philipaconrad
force-pushed
the
set-insert-rework
branch
2 times, most recently
from
August 12, 2022 17:29
d0410d4
to
9a28e3b
Compare
srenatus
previously approved these changes
Aug 15, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM one nitpick 😄
philipaconrad
force-pushed
the
set-insert-rework
branch
from
August 15, 2022 13:56
9a28e3b
to
a59aafd
Compare
srenatus
approved these changes
Aug 15, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Will update + squash-merge when green. 👍 |
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
philipaconrad
force-pushed
the
set-insert-rework
branch
from
August 15, 2022 14:13
a59aafd
to
ba1c4a5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces lazy key slice sorting for the Set datatype, similar to what was done in #4830 (Object Insertion Rework). After this change,
Set.Add()
will be an O(1) operation, and sorting of the Set type's key slice will be delayed until just-before-use, identically to how lazy key slice sorting is done for the Object type.This will move the sorting overhead from construction-time for Sets over to eval-time, allowing much more efficient construction and use of enormous (500k+ item) Sets. In small-scale tests, this appears to be a performance-neutral change overall, while dramatically improving performance for the "large set" edge case.
This PR also introduces a 2x new benchmarks for Sets, to keep parity with what we introduced for Objects:
BenchmarkSetCreationAndLookup
(Identical toBenchmarkObjectCreationAndLookup
)BenchmarkSetMarshalJSON
(We already benchmarkString()
operations separately for Sets)Note: This change is independent of the PR for improving the set
union
builtin (#4980), but very slightly improves performance there as well (around 5% or smaller improvement), likely from improved efficiency in Set construction.